import java.util.concurrent.TimeUnit;

/**
 * @Author: wangqiang20995
 * @Date:2019/3/22
 * @Description:
 * @Resource:
 */
public class DemoClass {
    public void start() {
        Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println(Thread.currentThread().getName());
                System.out.println("Execute Hook.....");
            }
        }));
    }

    public static void main(String[] args) {
        new DemoClass().start();
        System.out.println("The Application is doing something");

        try {
            TimeUnit.MILLISECONDS.sleep(5000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
